<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>
    <!-- vue 控制动画的标签 transition -->
    <!-- 初始化 appear  :appear="true" 或 appear-->
    <!-- name 区分不同动画 -->
    <transition name="zjl" appear>
      <h1 v-show="isShow">标签</h1>
    </transition>
  </div>
</template>

<script>
export default {
  name: "Test",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>

<style scoped>
h1 {
  background-color: orange;
}

/* vue 定义的名称 */
.zjl-enter-active {
  animation: donghua 0.5s linear;
}

/* vue 定义的名称 */
.zjl-leave-active {
  animation: donghua 0.5s linear reverse;
}

@keyframes donghua {
  from {
    transform: translatex(-100%);
  }
  to {
    transform: translateX(0);
  }
}
</style>
